package com.preserve.common.user.web;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.preserve.common.user.model.Users;
import com.preserve.common.user.service.IUsersService;

@Controller
@RequestMapping("/user")
public class UserController {

	@Resource
	IUsersService usersService;

	@RequestMapping(value = "create", method = RequestMethod.POST)
	public String create(Users u) throws Exception {
		// add
		usersService.save(u);
		return "/common/user/login";
	}

	/* 必须get&&set都支持 */
	@RequestMapping(value = "login")
	public String login() {
		return "/common/user/login";
	}

	@RequestMapping(value = "register")
	public String register() {
		return "/common/user/create";
	}

	@RequestMapping(value = "admin")
	public String admin() {
		return "/common/user/admin";
	}
}
